<script type="text/javascript">
    function parentRuleTreeNodeClick(event, treeId, treeNode) {
        var zTree = $.fn.zTree.getZTreeObj(treeId);
        var form = $.CurrentNavtab.find("#addRuleForm");
        zTree.checkNode(treeNode, !treeNode.checked, true, true);
        form.find("input[name='parentRuleName']").val(treeNode["name"]);
        form.find("input[name='pid']").val(treeNode["id"]);
        event.preventDefault();
    }
</script>
<div class="bjui-pageContent">
    <form id="addRuleForm" action="{:U('Admin/Auth/addRule')}" data-toggle="validate" data-alertmsg="false">
        <table class="table table-condensed table-hover" width="100%">
            <tbody>
                <tr>
                    <td>
                        <label for="title" class="control-label x85">权限中文名：</label>
                        <input type="text" name="title" id="title" value="" data-rule="required" size="20">
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="name" class="control-label x85">权限标识：</label>
                        <input type="text" name="name" id="name" value="" data-rule="required" size="20">
                        <span>(*英文,模块/控制器/方法)</span>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="pid" class="control-label x85">父级权限：</label>
                        <input type="text" name="parentRuleName" data-toggle="selectztree" value="" size="20" data-tree="#parentRuleTree" readonly>
                        <input type="hidden" name="pid" value="">
                        <ul id="parentRuleTree" class="ztree hide" data-toggle="ztree" data-expand-all="true" data-check-enable="true" data-chk-style="radio" data-radio-type="all" data-on-click="parentRuleTreeNodeClick">
                            <notempty name="parentRuleData">
                                <foreach name="parentRuleData" item="vo" key="k">
                                    <li data-id="{$vo.id}" data-pid="{$vo.pid}">{$vo.title}</li>
                                </foreach>
                            </notempty>
                        </ul>
                        <span>(*如果不选,默认顶级)</span>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="type" class="control-label x85">权限类型：</label>
                        <notempty name="ruleType">
                            <foreach name="ruleType" item="vo" key="k">
                                <input type="radio" name="type" data-toggle="icheck" value="{$k}" data-label="{$vo}" <if condition="$k eq 0">checked="checked"</if>>
                                &nbsp;&nbsp;
                            </foreach>
                        </notempty>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="status" class="control-label x85">权限状态：</label>
                        <notempty name="commonStatus">
                            <foreach name="commonStatus" item="vo" key="k">
                                <input type="radio" name="status" data-toggle="icheck" value="{$k}" data-label="{$vo}" <if condition="$k eq 1">checked="checked"</if>>
                                &nbsp;&nbsp;
                            </foreach>
                        </notempty>
                    </td>
                </tr>
                <tr>
                    <td>
                        <label for="sort" class="control-label x85">权限排序：</label>
                        <input type="text" name="sort" id="sort" value="0" size="20">
                        <span>(*值越小越前)</span>
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</div>
<div class="bjui-pageFooter">
    <ul>
        <li><button type="button" class="btn-close" data-icon="close">取消</button></li>
        <li><button type="submit" class="btn-default" data-icon="save">添加</button></li>
    </ul>
</div>